﻿using System;
using System.Collections.Generic;
using System.Text;

namespace FastMvc.Auth
{
    /// <summary>
    /// 指示该接口需要登录且需要对应的权限才可以调用
    /// </summary>
    public class PermissionCheckAttribute : Attribute
    {
        public string Permission { get; private set; }

        public string pName { get; set; }

        #region Crud权限配置
        /* 以下三个为配置CrudController时用的
         * 指示当前的CrudContoller中，是否需要有增加、修改、删除的权限
         * 默认都是False
         * TO_DO： 优雅一点....
         */

        /// <summary>
        /// 指示是否需要挂靠的Create权限
        /// </summary>
        public bool CrudCreate { get; set; } = false;

        /// <summary>
        /// 指示是否需要挂靠的Update权限
        /// </summary>
        public bool CrudUpdate { get; set; } = false;

        /// <summary>
        /// 指示是否需要挂靠的Delete权限
        /// </summary>
        public bool CrudDelete { get; set; } = false;
        #endregion

        public PermissionCheckAttribute(string permission, string name = "")
        {
            this.Permission = permission;
            if (!string.IsNullOrEmpty(name))
                pName = name;
            else
                pName = permission;
        }
    }

    /// <summary>
    /// 指示该接口无须登录既可调用(仅用在登录接口上？)
    /// </summary>
    public class NoneLoginCheckAttribute : Attribute
    {
        
    }
    
}
